package cn.kgc.music.controller;

import cn.kgc.music.pojo.Song;
import cn.kgc.music.service.SongService;
import com.alibaba.fastjson.JSON;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/song")
public class SongController {
    @Resource
    private SongService songService;

    @RequestMapping("/querySong.do")
    @ResponseBody
    public Map<String,Object> querysong(HttpServletRequest request){
        Map<String,Object> map=new HashMap<>();
        List<Song> songs = songService.querySong();
        System.out.println(songs.get(1).toString());
        if(songs!=null) {
            map.put("songs", songs);
            map.put("msg","未查询到数据");
        }else{
            map.put("msg","未查询到数据");
        }
        System.out.println(map);
//        String json= JSON.toJSONString(map);
        return map;
    }
}
